<html>
<head><meta charset="utf-8"><title>Types as const Parameters lang-team#61 · t-lang/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/index.html">t-lang/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html">Types as const Parameters lang-team#61</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213632276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213632276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213632276">(Oct 17 2020 at 03:00)</a>:</h4>
<p>A new proposal has been announced: <a href="https://github.com/rust-lang/lang-team/issues/61">Project Proposal: Types as const Parameters #61</a>. It will be announced at the next meeting to try and draw attention to it, but usually MCPs are not discussed during triage meetings. If you think this would benefit from discussion amongst the team, consider proposing a design meeting.</p>



<a name="213634976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213634976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213634976">(Oct 17 2020 at 04:34)</a>:</h4>
<p>Author of the proposal here; I’m open for any questions anyone has.  There’s a lot I haven’t worked out and a lot that’s fuzzy, but there’s also a fair bit of detail that the design more or less forces and that I can talk about but didn’t know how to fit into the proposal itself.</p>



<a name="213638906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213638906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213638906">(Oct 17 2020 at 06:58)</a>:</h4>
<p>at least on a surface level this looks quite similar to <code>zig</code>s comptime and is probably possible.</p>



<a name="213638982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213638982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213638982">(Oct 17 2020 at 07:01)</a>:</h4>
<p>I however do not feel that this is something we want to spend resources on in the near future as it is a really complex change without too much of a benefit</p>



<a name="213639079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639079">(Oct 17 2020 at 07:04)</a>:</h4>
<p>or... wait</p>



<a name="213639098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639098">(Oct 17 2020 at 07:06)</a>:</h4>
<p>I just looked into Zig’s <code>comptime</code>, and yeah, it’s quite similar…with the major difference being that this proposal still keeps all constraints checked at the declaration site, rather than Zig’s (and C++’s) “compile-time duck typing”.</p>



<a name="213639196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639196">(Oct 17 2020 at 07:09)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=4b43fce057cacd1894cf786f7864e401">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=4b43fce057cacd1894cf786f7864e401</a></p>



<a name="213639198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639198">(Oct 17 2020 at 07:09)</a>:</h4>
<p>doing this only requires some magic for <code>impl ToType for TyC&lt;...&gt;</code></p>



<a name="213639249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639249">(Oct 17 2020 at 07:10)</a>:</h4>
<p>Yeah.  And similarly for lifetimes, maybe?</p>



<a name="213639252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639252">(Oct 17 2020 at 07:10)</a>:</h4>
<p>lifetimes don't really make sense afaict</p>



<a name="213639254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639254">(Oct 17 2020 at 07:10)</a>:</h4>
<p>there isn't a semantic difference between <code>'a</code> and <code>'b</code> after all</p>



<a name="213639260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639260">(Oct 17 2020 at 07:11)</a>:</h4>
<p>or at least they would be more difficult to support</p>



<a name="213639262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639262">(Oct 17 2020 at 07:11)</a>:</h4>
<p>but considering that lt and types are sufficiently different this doesn't seem like a big issue imo</p>



<a name="213639266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639266">(Oct 17 2020 at 07:11)</a>:</h4>
<p><em>i am using a fairly liberal meaning of "some magic" here</em></p>



<a name="213639273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639273">(Oct 17 2020 at 07:11)</a>:</h4>
<p><em>this would still be the most complex builtin trait that exists</em></p>



<a name="213639310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639310">(Oct 17 2020 at 07:12)</a>:</h4>
<p>I suppose.  I figured they’d be needed for completeness because otherwise you might end up with APIs that take a slice of types but then have no way of pairing them with lifetimes they should be borrowed for.</p>



<a name="213639325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639325">(Oct 17 2020 at 07:13)</a>:</h4>
<p>The other thing I noticed is that we already <em>almost</em> have a runtime equivalent of <code>Type</code>: <a href="https://doc.rust-lang.org/std/any/struct.TypeId.html">https://doc.rust-lang.org/std/any/struct.TypeId.html</a></p>



<a name="213639335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639335">(Oct 17 2020 at 07:14)</a>:</h4>
<p>aaaaaaaaaaaaaaaaaaaaaaaaaa, that makes everything a lot harder i suppose</p>



<a name="213639386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639386">(Oct 17 2020 at 07:15)</a>:</h4>
<p>Wait, what does?</p>



<a name="213639759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639759">(Oct 17 2020 at 07:29)</a>:</h4>
<p>i think so</p>



<a name="213639762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639762">(Oct 17 2020 at 07:29)</a>:</h4>
<p>at least I don't know how to support additional generics this way</p>



<a name="213639764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639764">(Oct 17 2020 at 07:29)</a>:</h4>
<p>Oh.</p>



<a name="213639765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639765">(Oct 17 2020 at 07:29)</a>:</h4>
<p>and I think we would need additional generics to support lifetimes, I might be wrong though</p>



<a name="213639811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639811">(Oct 17 2020 at 07:30)</a>:</h4>
<p>Well, we <em>do</em> already have higher order <code>const fn</code>s.  That’s an obvious target for designating additional generics.</p>



<a name="213639814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639814">(Oct 17 2020 at 07:30)</a>:</h4>
<p>*desugaring, not designating</p>



<a name="213639910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213639910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213639910">(Oct 17 2020 at 07:34)</a>:</h4>
<p>It’s past sleep time for me; I’ll be back tomorrow morning!  😊</p>



<a name="213667469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213667469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213667469">(Oct 17 2020 at 19:38)</a>:</h4>
<p>I'm back!</p>



<a name="213685702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213685702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213685702">(Oct 18 2020 at 03:32)</a>:</h4>
<p>I like this because</p>



<a name="213685785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213685785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213685785">(Oct 18 2020 at 03:34)</a>:</h4>
<p>it would let us do computation in the trait system without the ugly “Prolog in trait impls” that’s currently required</p>



<a name="213685797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213685797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213685797">(Oct 18 2020 at 03:34)</a>:</h4>
<p>It would also provide a very natural path to compile-time reflection.</p>



<a name="213686676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213686676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213686676">(Oct 18 2020 at 04:00)</a>:</h4>
<p>I do like the idea of compile-time-only values.  I've wanted an "integer literal" type, for example, that could be infinite precision so things wouldn't need to pick between i128 or u128 or whatever.</p>
<p>Note that the implementation was already refactored so that generic params are an enum between Lifetime/Type/Const: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.GenericParamKind.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.GenericParamKind.html</a></p>
<p>All that said, I'm not sure that this solves the hard parts of variadic generics, like how to actually write code that uses them.  My inclination for now is to close/postpone this we've done with the other steps-to-variadic-generics RFCs.</p>



<a name="213688877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213688877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213688877">(Oct 18 2020 at 05:08)</a>:</h4>
<p>I'm cool with postponing this; I just wanted to put it in play, so to speak, so that smaller/more focused proposals didn't accidentally break or lock out the basic idea behind it by being unaware of it.</p>



<a name="213689407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689407">(Oct 18 2020 at 05:25)</a>:</h4>
<p>I’d contest that.  The big obstacle to variadic generics is the tension between, on one hand, “variadics should just be tuples, they shouldn’t be this huge complicated feature with limited and awkward ways to manipulate them, like in C++”… and on the other hand, “we have no way to reason generically about tuples”.</p>



<a name="213689466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689466">(Oct 18 2020 at 05:27)</a>:</h4>
<p>I'm also not quite sure what was meant about not solving "the hard parts"?</p>



<a name="213689516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689516">(Oct 18 2020 at 05:28)</a>:</h4>
<p>The way this works out would "solve" variadic generics the same way Rust "solves" variadic parameters to ordinary functions at runtime—by just passing in slices instead.</p>



<a name="213689517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689517">(Oct 18 2020 at 05:28)</a>:</h4>
<p>If we had compile-time reflection that included the ability to go back from “const-generic representation of a type” to the type itself, that would provide a way to do more complex things with arbitrary tuple types.</p>



<a name="213689575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689575">(Oct 18 2020 at 05:30)</a>:</h4>
<p>If that existed, you might still want some built-in syntax for doing <em>basic</em> things like “repeat this expression for each variadic argument”, but it wouldn’t have to be fully general if reflection were also available as an escape hatch.</p>



<a name="213689661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689661">(Oct 18 2020 at 05:33)</a>:</h4>
<p>Yeah.  I can certainly anticipate some simple use cases being worth introducing sugar for, but sugar is all it would be.</p>



<a name="213689719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689719">(Oct 18 2020 at 05:34)</a>:</h4>
<p>Oh, I think I see a difficulty <span class="user-mention" data-user-id="125270">@scottmcm</span> might have been forseeing, although I don't think it's a fundamental one.  Type definitions would have no way of <em>using</em> data structures full of types other than eventually blindly passing some munging of them to <code>std::tuple::Tuple</code>.  This would be immediately resolved by GADT support because then you could "pattern match" in each case, but perhaps there are simpler solutions too?</p>



<a name="213689738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689738">(Oct 18 2020 at 05:35)</a>:</h4>
<p>In particular I think introducing an <code>std::tuple::CoTuple</code> (or <code>AnonSum</code>, or <code>Choice</code>, or whatever we want to call it) would be sufficient, because the rest of it is then just computing the right nested structure of sums and products, which can be done in standard <code>const</code> Rust already.</p>



<a name="213689781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689781">(Oct 18 2020 at 05:36)</a>:</h4>
<p>Why would that be necessary?</p>



<a name="213689785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689785">(Oct 18 2020 at 05:36)</a>:</h4>
<p>well… what exactly do you want to pattern-match on?</p>



<a name="213689854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689854">(Oct 18 2020 at 05:38)</a>:</h4>
<p>What I’m envisioning is that there would be some <code>const</code> fn to, say, specialize a function or type with a given generic argument - like <code>foo::&lt;T&gt;</code> but where <code>T</code> is only known when the caller is executed rather than when it’s compiled (but this is all still at compile time)</p>



<a name="213689857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689857">(Oct 18 2020 at 05:38)</a>:</h4>
<p>Yes, I'm basically envisioning the same.</p>



<a name="213689862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689862">(Oct 18 2020 at 05:38)</a>:</h4>
<p>But this problem is unrelated to that.</p>



<a name="213689872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689872">(Oct 18 2020 at 05:39)</a>:</h4>
<p>If <code>foo</code> had trait bounds on that parameter and <code>T</code> didn’t satisfy them, it could panic, which the compiler could then format as a nice error</p>



<a name="213689877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689877">(Oct 18 2020 at 05:39)</a>:</h4>
<p>“it” = the specializing function</p>



<a name="213689942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689942">(Oct 18 2020 at 05:40)</a>:</h4>
<p>I’d also envision you’d be able to do comparisons between types if you do want to pattern match.  However, there is one big obstacle that also comes up with specialization, which is that lifetimes aren’t monomorphized.</p>



<a name="213689967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213689967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213689967">(Oct 18 2020 at 05:41)</a>:</h4>
<p>Say, for example, I'm building something like the “optionally typed box” I mentioned in the proposal text.  The obvious shape of the definition is:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">enum</span> <span class="nc">OTBox</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">optT</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="n">Type</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Typed</span><span class="p">(</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">),</span><span class="w"> </span><span class="c1">// How do I get T out of optT?</span>
<span class="w">    </span><span class="n">Untyped</span><span class="p">(</span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">Any</span><span class="o">&gt;</span><span class="p">),</span><span class="w"> </span><span class="c1">// How do I ensure this case is only used at type OTBox&lt;{None}&gt;?</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>

<p>But I don't know how to solve the two comments without GADTs or the above <code>std::tuple::AnonSum</code> (which are equivalent in power given the rest of this proposal).</p>



<a name="213690058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690058">(Oct 18 2020 at 05:43)</a>:</h4>
<p>...so you can’t just have an Eq implementation for types, because if the types contain lifetimes, the compiler doesn’t know whether they’re equal or not.  For the same monomorphized function, they could be equal or not equal depending on how the function is used.</p>



<a name="213690111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690111">(Oct 18 2020 at 05:44)</a>:</h4>
<p>“ How do I get T out of optT?”</p>



<a name="213690115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690115">(Oct 18 2020 at 05:44)</a>:</h4>
<p>why not just <code>optT.unwrap()</code>?</p>



<a name="213690126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690126">(Oct 18 2020 at 05:45)</a>:</h4>
<p>oh, I see, it might be None</p>



<a name="213690127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690127">(Oct 18 2020 at 05:45)</a>:</h4>
<p>Yeah.</p>



<a name="213690191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690191">(Oct 18 2020 at 05:46)</a>:</h4>
<p>Then you’d have a single field of type <code>match optT { Some(T) =&gt; Box&lt;T&gt;, None =&gt; Box&lt;Any&gt; }</code></p>



<a name="213690204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690204">(Oct 18 2020 at 05:46)</a>:</h4>
<p>Oh.  Yes, you're right, and I'm not thinking.</p>



<a name="213690207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690207">(Oct 18 2020 at 05:46)</a>:</h4>
<p>That's quite simple.</p>



<a name="213690217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690217">(Oct 18 2020 at 05:46)</a>:</h4>
<p>Just pattern match on the Option by <em>actually pattern matching</em>.</p>



<a name="213690221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690221">(Oct 18 2020 at 05:46)</a>:</h4>
<p>Also, there's nothing stopping a <code>PartialEq</code> implementation for types, and that's the more theoretically correct approach anyway.  Types that can't be proven distinct and also can't be proven equal…just aren't equal and aren't unequal.  It's no worse than floats, right?</p>



<a name="213690329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690329">(Oct 18 2020 at 05:49)</a>:</h4>
<p>In theory… although I think it might be too surprising to literally implement PartialEq; I think floats only get away with it because NaNs are usually not what you want to compare against anyway (and they still confuse the heck out of people)</p>



<a name="213690375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690375">(Oct 18 2020 at 05:50)</a>:</h4>
<p>Hm.</p>



<a name="213690409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690409">(Oct 18 2020 at 05:51)</a>:</h4>
<p>But more generally, one proposal for sound specialization boils down to having predicates of the form “is this trait bound guaranteed to hold regardless of the values of any lifetime parameters”, and I think you’d want a similar concept in a reflection API.</p>



<a name="213690414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690414">(Oct 18 2020 at 05:52)</a>:</h4>
<p>For the sake of putting types in data structures that need proper reflexive equality, we could provide a pair of newtypes that implement the conservative and liberal approximations to the partial equality.  One would resolve undecideds to false and the other would resolve them to true.  That way the user gets exactly the semantics they ask for, and if they <em>don't</em> ask for one, we force them to choose.</p>



<a name="213690452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690452">(Oct 18 2020 at 05:52)</a>:</h4>
<p>But this is getting off in the weeds.</p>



<a name="213690545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690545">(Oct 18 2020 at 05:54)</a>:</h4>
<p>I think your musings about predicates on types is just making <code>std::type_level::Constraint</code>, as I described it, more obviously useful.</p>



<a name="213690576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690576">(Oct 18 2020 at 05:56)</a>:</h4>
<p>Oh my god.  I just realized:  with this proposal as it stands, we <em>already</em> have <code>AnonSum</code>.</p>



<a name="213690619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690619">(Oct 18 2020 at 05:56)</a>:</h4>
<p><span class="user-mention" data-user-id="262628">@Alexander Ronald Altman</span> I'm picturing difficulties like "how do I make an enum with one variant for each of the types in the variadic generic?", for example.  (Like if I wanted to make a <code>VariadicEither</code> type.)  Or "what's the rust equivalent of C++'s <a href="https://en.cppreference.com/w/cpp/language/fold">fold expressions</a>?"</p>



<a name="213690626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690626">(Oct 18 2020 at 05:56)</a>:</h4>
<p>I'm just about to answer that first question right now!  That's the epiphany I just had!  <span aria-label="happy" class="emoji emoji-1f600" role="img" title="happy">:happy:</span></p>



<a name="213690641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690641">(Oct 18 2020 at 05:57)</a>:</h4>
<p>(Basically, <em>having</em> the parameter values is easy compared to actually being able to <em>use</em> or <em>infer</em> them.)</p>



<a name="213690711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690711">(Oct 18 2020 at 05:59)</a>:</h4>
<p>All you need is <code>PhantomData</code> and <code>for</code> for all types of generic parameters, not just types/lifetimes.</p>



<a name="213690714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690714">(Oct 18 2020 at 05:59)</a>:</h4>
<p>Then you do:</p>



<a name="213690775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690775">(Oct 18 2020 at 06:00)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">AnonSum</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">tys</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="n">Type</span><span class="p">]</span><span class="o">&gt;</span><span class="p">(</span><span class="k">for</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">i</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="p">(</span><span class="n">PhantomData</span><span class="o">&lt;</span><span class="p">{</span><span class="n">i</span><span class="p">}</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="n">tys</span><span class="p">[</span><span class="n">i</span><span class="p">]}))</span><span class="w"></span>
</code></pre></div>



<a name="213690790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690790">(Oct 18 2020 at 06:01)</a>:</h4>
<p>Oh wait.  We need an existential, not a universal.  Never mind.  <span aria-label="confused" class="emoji emoji-1f615" role="img" title="confused">:confused:</span></p>



<a name="213690802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690802">(Oct 18 2020 at 06:01)</a>:</h4>
<p>Maybe the core idea is still salvagable though?</p>



<a name="213690941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213690941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213690941">(Oct 18 2020 at 06:05)</a>:</h4>
<p>We basically need <code>const</code> sigma types, don't we, for that.  D:</p>



<a name="213691018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691018">(Oct 18 2020 at 06:07)</a>:</h4>
<p>Wait.  Isn't that what trait objects are for?</p>



<a name="213691021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691021">(Oct 18 2020 at 06:07)</a>:</h4>
<p>Or dynsize things in general, I guess?</p>



<a name="213691070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691070">(Oct 18 2020 at 06:09)</a>:</h4>
<p><code>AnonSum&lt;{tys}&gt;</code> is a pair of an index into <code>tys</code> and a value of the type at that index.  The latter is the "data" and the former is the "metadata" of a dynamically sized type, yeah?</p>



<a name="213691130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691130">(Oct 18 2020 at 06:10)</a>:</h4>
<p>I do see how, no matter what path forward is favored, this proposal <em>by itself</em> is not enough to solve that.  <span aria-label="frown" class="emoji emoji-1f641" role="img" title="frown">:frown:</span></p>



<a name="213691193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691193">(Oct 18 2020 at 06:12)</a>:</h4>
<p>“Fold expressions” should be easy though:  they're literally just a normal fold call, or any other iterator method, on the <code>iter</code> of the <code>const</code> slice.</p>



<a name="213691212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691212">(Oct 18 2020 at 06:12)</a>:</h4>
<p>Let's take the example on that page.  In the original C++:</p>
<div class="codehilite" data-code-language="C++"><pre><span></span><code><span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span><span class="p">...</span> <span class="n">Args</span><span class="o">&gt;</span>
<span class="kt">bool</span> <span class="n">all</span><span class="p">(</span><span class="n">Args</span><span class="p">...</span> <span class="n">args</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="p">(...</span> <span class="o">&amp;&amp;</span> <span class="n">args</span><span class="p">);</span> <span class="p">}</span>
</code></pre></div>



<a name="213691263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691263">(Oct 18 2020 at 06:14)</a>:</h4>
<p>Oh, wait, that's not a good example because it relies on C++'s weirdness around <code>&amp;&amp;</code> and its lack of declaration-site type checking.</p>



<a name="213691270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691270">(Oct 18 2020 at 06:14)</a>:</h4>
<p>Uh…challenge ideas welcome, I guess?  <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="213691281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691281">(Oct 18 2020 at 06:15)</a>:</h4>
<p>Function that takes a bunch of arguments and <code>println!</code>s them all.</p>



<a name="213691285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691285">(Oct 18 2020 at 06:15)</a>:</h4>
<p>Okay!</p>



<a name="213691339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691339">(Oct 18 2020 at 06:17)</a>:</h4>
<p>Wait, how is that a challenge for this proposal?</p>



<a name="213691345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691345">(Oct 18 2020 at 06:17)</a>:</h4>
<p>An arbitrary number of arguments.</p>



<a name="213691392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691392">(Oct 18 2020 at 06:18)</a>:</h4>
<p>Oh, I see, yeah.</p>



<a name="213691393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691393">(Oct 18 2020 at 06:18)</a>:</h4>
<p>The most natural approach is recursive, but choosing between the base case and the recursive case is difficult.</p>



<a name="213691396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691396">(Oct 18 2020 at 06:18)</a>:</h4>
<p>Well, in the absence of varargs functions, use a tuple, right?</p>



<a name="213691400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691400">(Oct 18 2020 at 06:19)</a>:</h4>
<p>Sure.</p>



<a name="213691408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691408">(Oct 18 2020 at 06:19)</a>:</h4>
<p>One easy way to distinguish would be if Rust had an equivalent of <code>if constexpr</code>.  Without that, I think it still can be done through the trait system, but it would be ugly.</p>



<a name="213691465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691465">(Oct 18 2020 at 06:21)</a>:</h4>
<p>Anyway, I’m going to sleep, but I’d like to see what you  come up with.</p>



<a name="213691466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691466">(Oct 18 2020 at 06:21)</a>:</h4>
<p>(This is one of those places where templates are easier for C++, since it doesn't need to check things until invoked.)</p>



<a name="213691467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691467">(Oct 18 2020 at 06:21)</a>:</h4>
<p>I'm typing it up right now.</p>



<a name="213691474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691474">(Oct 18 2020 at 06:21)</a>:</h4>
<p>Slightly strawmanned syntax, but not too badly.</p>



<a name="213691516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691516">(Oct 18 2020 at 06:22)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">printlnAll</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">tys</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="n">Type</span><span class="p">]</span><span class="o">&gt;</span><span class="p">(</span><span class="n">values</span>: <span class="nc">Tuple</span><span class="o">&lt;</span><span class="p">{</span><span class="n">tys</span><span class="p">}</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="p">{</span><span class="n">tys</span><span class="p">.</span><span class="n">iter</span><span class="p">().</span><span class="n">all</span><span class="p">(</span><span class="o">|</span><span class="n">ty</span><span class="o">|</span><span class="w"> </span><span class="p">({</span><span class="n">ty</span><span class="p">}</span>: <span class="nc">Display</span><span class="p">))}</span><span class="w"></span>
<span class="w">    </span><span class="k">for</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="n">tys</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">println</span><span class="o">!</span><span class="p">(</span><span class="s">"{}"</span><span class="p">,</span><span class="w"> </span><span class="n">values</span><span class="p">.{</span><span class="n">i</span><span class="p">})</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="213691528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691528">(Oct 18 2020 at 06:22)</a>:</h4>
<p>Yeah?</p>



<a name="213691608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691608">(Oct 18 2020 at 06:25)</a>:</h4>
<p>Good start, but that <code>for</code> loop can’t exist at runtime, so with that approach it would need to be some new “compile time <code>for</code>” construct.  And how does it type check?  How do we reassure the compiler that <code>values.{i}: Display</code> in a way it understands?</p>



<a name="213691648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691648">(Oct 18 2020 at 06:26)</a>:</h4>
<p>I see the problem with <code>const for</code>.</p>



<a name="213691660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691660">(Oct 18 2020 at 06:27)</a>:</h4>
<p>Anyway, going to sleep for real this time.</p>



<a name="213691662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691662">(Oct 18 2020 at 06:27)</a>:</h4>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="213691769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691769">(Oct 18 2020 at 06:30)</a>:</h4>
<p>Checking that each type implements <code>Display</code> is done already though, given a <code>const for</code>.  The compiler knows, in the body of the compile-time loop, that we need <code>Display</code> for <code>values.{i}</code>, so it looks up the type and finds <code>tys[i]</code>, which is a type variable, so it asks after the known properties of it…which include <code>Display</code> because that was required on the outside by iterating over all of <code>tys</code>.</p>



<a name="213691787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/Types%20as%20const%20Parameters%20lang-team%2361/near/213691787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Ronald Altman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/Types.20as.20const.20Parameters.20lang-team.2361.html#213691787">(Oct 18 2020 at 06:31)</a>:</h4>
<p>I should go to sleep myself soon.  Goodnight, all!  <span aria-label="sleeping" class="emoji emoji-1f634" role="img" title="sleeping">:sleeping:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>